package llm

type Token struct {
	token  string
	expire int64
}

type Model interface {
	RefreshToken() error
	CallApi(system_prompt, user_prompt string) (string, error)
}

type TranslateRsp struct {
	Lang        string    `json:"lang"`
	Explain     string    `json:"explain"`
	Translation string    `json:"translation"`
	Keywords    []Keyword `json:"keywords"`
	Typos       []Typo    `json:"typos"`
	Elapse      int64     `json:"elapse"`
	Model       string    `json:"model"`
}

func (rsp *TranslateRsp) IsProgramCode() bool {
	return rsp.Lang == "program"
}

type Keyword struct {
	Keyword string `json:"keyword"`
	Ame     string `json:"ame"`
	Explain string `json:"explain"`
}

func (k *Keyword) FormatAme() string {
	if k.Ame == "" {
		return ""
	}
	if k.Ame[0] == '/' {
		return k.Ame
	}
	return "/" + k.Ame + "/"
}

type Typo struct {
	Typo    string `json:"typo"`
	Correct string `json:"correct"`
}
